<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
<!doctype html>
<html lang="zh">
<head>
    <title>添加请假单</title>
    <%@include file="/common/header.jspf"%>
</head>
<body>
<div class="form-wrap">
    <form id="leaveForm" method="post">
        <div class="input-wrap">
            <label class="label-top">请假类型:</label>
            <select name="type" style="width: 300px;height:30px;">
                <option value="0">事假</option>
                <option value="1">婚假</option>
            </select>
        </div>
        <div class="input-wrap">
            <label class="label-top tip_code">开始时间:</label>
            <input class="easyui-textbox " name="startDate" data-options="required:true,validType:'checkCode'" style="width: 300px;" title=""/>
        </div>
        <div class="input-wrap">
            <label class="label-top">结束时间:</label>
            <input class="easyui-textbox "  name="endDate" data-options="required:true" style="width: 300px;" title=""/>
        </div>
        <div class="input-wrap">
            <label class="label-top">请假天数:</label>
            <input class="easyui-numberspinner "  name="leaveDay" value="0" style="width: 360px;" title=""/>
        </div>
        <div class="input-wrap">
            <label class="label-top">请假内容:</label>
            <input class="easyui-textbox " name="content" data-options="prompt:'填写备注',multiline:true"  style="height:60px;width: 360px;" title=""/>
        </div>

    </form>
    <div class="form-button">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="fa fa-save fa-lg" id="leaveSave" >保存</a>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        /***
         * 提交操作
         */
        $('#leaveSave').on("click", function () {

            $.messager.progress();	// 显示进度条
            var data=$("#leaveForm").serializeJson();
            $('#leaveForm').form('submit', {
                url: ROOT_PATH + '/workflow/demo/addLeaveApplication.shtml',
                data:data,
                onSubmit: function (param) {
                    return true;	// 返回false终止表单提交
                },
                success: function (result) {
                    try {
                        result = $.parseJSON(result);
                    }catch (e) {
                        $.messager.progress('close');
                        parent.layer.msg(result.message,{time:1000,icon:2});
                    }
                    if (result.success){
                        $.messager.progress('close');	// 如果提交成功则隐藏进度条
                        parent.layer.msg(result.message,{time:1000,icon:1},function () {
                            parent.$('#dg1').datagrid('load');
                            parent.layer.closeAll(); //先得到当前iframe层的索引
                        });
                    }else {
                        $.messager.progress('close');	// 如果提交失败则不做处理
                        parent.layer.msg(result.message,{time:1000,icon:2});
                    }
                }
            });
        });


    });
</script>
</body>
</html>
